Load predictions data frame.
Create Table summaries https://cran.r-project.org/web/packages/arsenal/vignettes/tableby.html
| 1980 (N=83400) | 1990 (N=83400) | 2000 (N=83400) | 2010 (N=75060) | Total (N=325260) | p value | |
|---|---|---|---|---|---|---|
| preds | < 0.001 | |||||
| - Mean (SD) | 7.602 (2.128) | 8.200 (2.257) | 8.270 (2.285) | 8.407 (2.462) | 8.112 (2.302) | |
| - Range | -2.554 - 14.826 | -2.274 - 17.202 | -1.713 - 16.421 | -1.960 - 18.316 | -2.554 - 18.316 |
| 1980 (N=86180) | 1990 (N=86180) | 2000 (N=86180) | 2010 (N=77562) | Total (N=336102) | p value | |
|---|---|---|---|---|---|---|
| preds | < 0.001 | |||||
| Â Â Â Mean (SD) | 9.750 (1.830) | 10.045 (1.871) | 10.396 (2.115) | 10.237 (2.144) | 10.104 (2.006) | |
| Â Â Â Range | -0.214 - 15.915 | 0.848 - 16.942 | 0.779 - 18.486 | 0.282 - 17.533 | -0.214 - 18.486 |
| 1980 (N=86180) | 1990 (N=86180) | 2000 (N=86180) | 2010 (N=77562) | Total (N=336102) | p value | |
|---|---|---|---|---|---|---|
| preds | < 0.001 | |||||
| Â Â Â Mean (SD) | 9.268 (1.863) | 9.366 (2.002) | 9.770 (1.987) | 9.393 (1.875) | 9.451 (1.944) | |
| Â Â Â Range | 1.532 - 15.252 | -0.107 - 15.662 | 2.338 - 16.831 | 1.559 - 15.721 | -0.107 - 16.831 |
| 1980 (N=83400) | 1990 (N=83400) | 2000 (N=83400) | 2010 (N=75060) | Total (N=325260) | p value | |
|---|---|---|---|---|---|---|
| preds | < 0.001 | |||||
| Â Â Â Mean (SD) | 6.166 (2.154) | 6.300 (2.532) | 6.437 (2.217) | 6.435 (2.360) | 6.332 (2.322) | |
| Â Â Â Range | -4.262 - 14.084 | -5.141 - 12.999 | -2.734 - 12.382 | -3.180 - 13.451 | -5.141 - 14.084 |
#Plot average daily temperatures across 38 year period
Plot yearly summaries faceted by decade
Animate by Year using gganimate https://www.datanovia.com/en/blog/gganimate-how-to-create-plots-with-beautiful-animation-in-r/
#try gganimate method
#shadow fade with old years in background
theme_set(theme_bw())
ani <- ggplot(all_years, aes(x = day, y = mean_yr, color = as.factor(year))) +
geom_smooth(se=FALSE, show.legend = FALSE) +
scale_size(range = c(2, 12)) +
transition_states(year, transition_length = 1, state_length = 1) + shadow_mark(alpha=0.3, size=0.7) +
transition_time (year) +
labs(x = "Day of Year", y = "Daily mean Stream Temperature", title = "Year: {as.integer(frame_time)}")
animate(ani, duration=50, fps=1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
#try the "Let data gradually appear" with month time series
K_p2 <- preds %>% mutate(month=month(date), day2=(day(date))) %>% mutate(decade=case_when(year< 1990 ~ 1980, year >= 1990 & year < 2000 ~ 1990, year >=2000 & year < 2010 ~ 2000, year>2009 ~ 2010)) %>% filter(K_p == 1)
all_years2 <- K_p2 %>% group_by(month, day2) %>%
summarize(mean_mth = mean(preds))
ani2 <- ggplot(all_years2, aes(x = day2, y = mean_mth, color=factor(month))) +
geom_line() +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures 1980-2018")
ani2 + transition_reveal(day2)
Animate months by decade
all_years22 <- K_p2 %>% group_by(month, day2, decade) %>%
summarize(mean_mth_dec = mean(preds))
ani3 <- ggplot(all_years22, aes(x = day2, y = mean_mth_dec, color=factor(month))) +
geom_line() +
labs(x = "Day of Month", y = "Stream Temperature", title = "Average Daily Temperatures by decade")
ani3 + transition_reveal(day2) + facet_wrap(~decade)
Summarize predictions by decades and plot
Calculate and plot Temperature Anomolies! Calculate annual mean 1980-2018 then yearly differences between 38 year mean. #Filter for spawning time period - Chinook reach their spawning areas between July and September - DESCENDING LIMB!!!!
#Filter for core rearing - June-August